const mongoose = require('mongoose');
const shortid = require('shortid');
const DbSet = require('./db')
const Schema = mongoose.Schema;
const GamesSchema = new Schema({
    _id: {
        type: String,
        default: shortid.generate,
        unique: true
    },
    gameid: {
        type: String,
        require: true
    },
    gamename: {
        type: String,
        require: true
    },
    gameer: {
        type: String,
    },
    gameer_img: {
        type: String
    },
    gameer_bimg: {
        type: Array
    },
    //游戏类型
    gametype: {
        type: Array,
        require: true
    },
    //游戏简介
    gamemotto: {
        type: String,
        default: '这真是一个好游戏'
    },
    //游戏图片
    gameavatar: {
        type: String,
    },
    //上架时间
    gametime: {
        type: Date,
        default: Date.now
    },
    //厂商
    gameer_poeple: {
        type: String
    },
    //like
    likes: {
        type: Boolean,
        default: false,
    },
    //文件大小
    game_big: {
        type: Number,
    },
    // 留言数量
    gamearticle_count: {
        type: Number,
        default: 0
    },
    // 点击数量
    click_count: {
        type: Number,
        default: 0
    },
    // 购买数量
    buy_count: {
        type: Number,
        default: 0
    },
    //价格
    gameprize: {
        type: String,
    },
    //评论数量
    game_reply: {
        type: Number
    }

})
GamesSchema.statics = {
    findByidone: (id, callback) => {
        Games.findOne({ gameid: id, }).then((gameone) => {
            return callback(null, gameone)
        }).catch((err) => {
            return callback(err)
        })
    }
}

const Games = mongoose.model('Games', GamesSchema);
module.exports = Games;
